package org.jakim.utils;

import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class Utils {

	public static String generateHTMLDates(Date startDate, Date endDate) {
		StringBuffer dateValue = new StringBuffer();
		Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
		cal.setTime(startDate);
		dateValue.append(cal.getDisplayName(Calendar.MONTH, Calendar.ALL_STYLES, Locale.getDefault())).append(" ").append(cal.get(Calendar.YEAR));

		if (null == endDate) {
			dateValue.append(" onwards");
		} else {
			cal.setTime(endDate);
			dateValue.append(" - ").append(cal.getDisplayName(Calendar.MONTH, Calendar.ALL_STYLES, Locale.getDefault())).append(" ").append(cal.get(Calendar.YEAR));
		}

		dateValue.trimToSize();
		return dateValue.toString();
	}
	
	public static String generatHTMLStringConcats(String... args){
		StringBuffer concatedValue = new StringBuffer();
		for (String str: args){
			concatedValue.append(str.trim()).append(System.lineSeparator());
		}
		
		return concatedValue.toString().trim();
	}
	
	public static String generatHTMLStringConcats(char delimiter, String... args){
		StringBuffer concatedValue = new StringBuffer();
		for (String str: args){
			concatedValue.append(str.trim()).append(delimiter);
		}
		
		// removes the last added delimiter.
		concatedValue.delete(concatedValue.length() - 1, concatedValue.length());
		
		return concatedValue.toString().trim();
	}
}
